package com.bdsy.business.controller;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bdsy.api.annotation.IgnoreAuth;
import com.bdsy.business.model.Order;
import com.bdsy.business.model.OrderDetails;
import com.bdsy.business.model.ScaveRecord;
import com.bdsy.business.service.OrderService;
import com.bdsy.business.service.ScaveRecordService;
import com.bdsy.common.annotation.Json;
import com.bdsy.common.utils.DateRandomUtil;
import com.bdsy.common.utils.Result;
import com.bdsy.system.annotation.SysLog;

/**
 * 扫码记录
 * @author MING
 * @date 2018年1月8日 上午10:58:56
 */
@Controller
@RequestMapping(value = {"${web.adminPath}", "${web.appPath}"})
public class ScaveRecordController {

	@Autowired
	ScaveRecordService scaveRecordService;
	
	/**
	 * 查询扫描记录信息
	 */
	@IgnoreAuth
	@Json
	@RequestMapping(value = "selectScaveRecordById")
	public Object selectScaveRecordById(String userId) {
		
		Map<String,Object> map = new LinkedHashMap<>();
		
		@SuppressWarnings("rawtypes")
		List<Map> scaveRecordList = scaveRecordService.selectScaveRecordById(userId);
		//查询扫描记录信息
		int count = scaveRecordService.count(userId);
		map.put("code", 200);
		map.put("msg", "success");
		map.put("total", count);
		map.put("data", scaveRecordList);
		return map;
	}
		
	/**
	 * 添加扫描记录信息
	 */
	@Json
	@RequestMapping(value = "addScaveRecord")
	public Object addScaveRecord(ScaveRecord scaveRecord) {
		boolean result = scaveRecordService.insert(scaveRecord);
		if (result) {
			return Result.ok("addSuccess");
		} else {
			return Result.error("addFail");
		}
	}
	
}
